﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Iesi.Collections;

namespace Eg.ManualRelationships
{
    public class OrderItem
    {
        public virtual Guid Id { get; protected set; }
        public virtual Order Order { get; protected set; }

        public virtual void SetOrder(Order newOrder)
        {
            var preOrder = Order;
            if (newOrder == preOrder)
            {
                return;
            }

            Order = newOrder;

            if (preOrder != null)
            {
                preOrder.RemoveItem(this);
            }
            if (newOrder != null)
            {
                newOrder.AddItem(this);
            }
        }
    }
}
